<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-3-26
 * Time: 下午9:53
 */

class ClientInfoModel extends Model{
    protected $tableName = 'client_info';

    /**
     * 获取客户基本信息
     * @param string $field
     * @return mixed
     */
    public function getClient($map,$size=15,$field='*')
    {
        $count = $this->where($map)->count();
        $data = $this->where($map)->field($field)->pager($count,$size);

        foreach($data['data'] as &$value){
            $value['tel'] = json_decode($value);
            $value['emo_info'] = json_decode($value);
            $value['spouse'] = json_decode($value);
            $value['parents'] = json_decode($value);
            $value['children'] = json_decode($value);
        }

        return $data;
    }

    /**
     * 获取一条客户信息
     * @param int $id ID
     * @param $field
     * @return mixed
     */
    public function getListClient($id,$field)
    {
        return $this->where(array('id'=>$id))->field($field)->find();
    }
} 